package com.xl.sst.controller;




import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xl.sst.biz.TouziBiz;
import com.xl.sst.vo.Touzi;




/*
 * 投资处理层
 * yue
 */
@Controller
@RequestMapping("/view")
public class TouziController {
	@Resource
	public TouziBiz touziBiz;	
	public TouziBiz getTouziBiz() {
		return touziBiz;
	}
	public void setTouziBiz(TouziBiz touziBiz) {
		this.touziBiz = touziBiz;
	}
	/*
	 * 获取所有的投资信息
	 * http://localhost:8080/SST/view/selectAllTouzi.do
	 */
	@RequestMapping("/selectAllTouzi.do")
	public @ResponseBody List<Touzi> selectAll(){
		return touziBiz.selectAll();	
		
	}
	/*
	 * 获取所有的投资信息
	 * http://localhost:8080/SST/view/touziAdd.do
	 */
	@RequestMapping("/touziAdd.do")
	public @ResponseBody String touziAdd(Touzi z){
		//设置编号
		long s = new Date().getTime();  
		z.setNum(String.valueOf(s).substring(String.valueOf(s).length()-10, String.valueOf(s).length()));
		if(touziBiz.touziAdd(z)){
			return "添加失败！";
		}else{
			return "添加成功！";	
		}
	}
	/*
	 * 有人投资时候修改
	 * http://localhost:8080/SST/view/touziAdd.do
	 */
	@RequestMapping("/touziUpdate.do")
	public @ResponseBody String touziUpdate(Touzi z){		
		if(touziBiz.touziUpdate(z) && touziBiz.touziUserUpDate(z)){
			return "投资成功！";
		}else{
			return "投资失败！";	
		}
	}
	/*
	 * 投资状态改变 
	 */
	@RequestMapping("/touziHide.do")
	public @ResponseBody String touziHide(Touzi z){		
		if(touziBiz.touziHide(z)){
			return "下架成功！";
		}else{
			return "下架失败！";	
		}
	}
}
